{{ define "home/register" }}

  {{template "home/header" .}}

  <div class="container">
    <div class="columns">
      <div class="column is-4 is-offset-4 login">

        <div class="login-plan">
          <div class="control">
            <h2>{{.title}}</h2>
          </div>
          <div class="control">
            <label for="">邮箱</label>
            <input class="input" type="email" id="email">
          </div>

          <div class="control">
            <label for="">密码</label>
            <input class="input" type="password" id="password">
          </div>

          <div class="control">
            <button class="button is-info is-fullwidth" id="signButton">注册</button>
          </div>
        </div>

        <div class="regist-plan">
         已经有账号，前去<a href="/oauth/authorize">登录</a>.
        </div>

      </div>
    </div>
  </div>

  {{template "home/footer" .}}

  <!-- 请求脚本 -->

  <script>

    $("#signButton").click(function () {

      var data = {
        email: $("#email").val(),
        password: $("#password").val(),
      }

      $.ajax({
        type: 'POST',
        url: "/oauth/register",
        data: data,
        success: function (res) {
          if (res.code == 200) {
            window.location.href = "/oauth/authorize";
          } else {
            alert(res.msg);
          }
        },
        dataType: "json"
      })

    })

  </script>

{{ end }}
